package com.xbao.dao;

import com.xbao.model.MAnswer;
import com.xbao.model.MAnswerExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface MAnswerMapper {
    @SelectProvider(type=MAnswerSqlProvider.class, method="countByExample")
    int countByExample(MAnswerExample example);

    @DeleteProvider(type=MAnswerSqlProvider.class, method="deleteByExample")
    int deleteByExample(MAnswerExample example);

    @Delete({
        "delete from manswer",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into manswer (title, createtime, ",
        "contents)",
        "values (#{title,jdbcType=VARCHAR}, #{createtime,jdbcType=BIGINT}, ",
        "#{contents,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MAnswer record);

    @InsertProvider(type=MAnswerSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(MAnswer record);

    @SelectProvider(type=MAnswerSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="contents", property="contents", jdbcType=JdbcType.VARCHAR)
    })
    List<MAnswer> selectByExample(MAnswerExample example);

    @Select({
        "select",
        "id, title, createtime, contents",
        "from manswer",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="contents", property="contents", jdbcType=JdbcType.VARCHAR)
    })
    MAnswer selectByPrimaryKey(Long id);

    @UpdateProvider(type=MAnswerSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") MAnswer record, @Param("example") MAnswerExample example);

    @UpdateProvider(type=MAnswerSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") MAnswer record, @Param("example") MAnswerExample example);

    @UpdateProvider(type=MAnswerSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MAnswer record);

    @Update({
        "update manswer",
        "set title = #{title,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "contents = #{contents,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MAnswer record);
}